package com.yonder.gocommand.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yonder.gocommand.dao.IItemDAO;
import com.yonder.gocommand.entity.Item;
import com.yonder.gocommand.service.IItemService;

@Service("ItemService")
@Transactional
public class ItemServiceImpl implements IItemService {

	private static final Logger LOGGER = LoggerFactory.getLogger(IItemService.class);
	private Date currentDateTime = new Date();
	private SimpleDateFormat sdf = new SimpleDateFormat("HH:mm dd/MM/yyyy");

	@Autowired
	private IItemDAO itemDAO;

	@Override
	public void saveOrUpdate(Item i) {
		LOGGER.info("saveOrUpdate: " + i.getName()+ " " + sdf.format(currentDateTime));
		itemDAO.saveOrUpdate(i);
	}

}
